package com.gitee.absolute_spirit.hiot_android.data.source.network

import com.gitee.absolute_spirit.hiot_android.ui.home.HomeViewState
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

import javax.inject.Inject

class DeviceNetworkRepository @Inject constructor(
    private val dao: DeviceNetworkDao
) {
    suspend fun getAll(): List<HomeViewState> {
        return dao.getAll().toHomeViewState()
    }

    val getAllFlow: Flow<List<HomeViewState>> =  dao.devices.map { devices ->
            devices.toHomeViewState()
        }
}